package action.main;

import java.util.List;
import service.MainService;
import util.ObjectFactory;
import entity.Book;
import entity.Category;

public class BookListAction {
	//input
	private int page=1;
	private int cid;//子ID
	private int pid;//父ID
	private String value;//排序字段
	//output
	private List<Book> books;
	private List<Category> cates;
	private int count; //总数量
	private int totalPage;
	private List<String> cateNames;//栏目导航信息
	//injection
	private MainService mainService;
	public void setMainService(MainService mainService) {
		this.mainService = mainService;
	}
	
	public String execute() throws Exception{
		MainService service = ObjectFactory.getInstance(MainService.class);
		cates=mainService.findLeftBookListCategory(pid);
		books=mainService.findBooks(page, value, cid);
		count=mainService.getCount(pid);
		totalPage=mainService.findTotalPage(cid);
		cateNames=mainService.findNavigation(cid);
		return "success";
	}

	public int getCid() {
		return cid;
	}

	public void setCid(int cid) {
		this.cid = cid;
	}

	public List<Book> getBooks() {
		return books;
	}

	public void setBooks(List<Book> books) {
		this.books = books;
	}

	public List<Category> getCates() {
		return cates;
	}

	public void setCates(List<Category> cates) {
		this.cates = cates;
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public int getTotalPage() {
		return totalPage;
	}

	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}

	public List<String> getCateNames() {
		return cateNames;
	}

	public void setCateNames(List<String> cateNames) {
		this.cateNames = cateNames;
	}

	public int getPid() {
		return pid;
	}

	public void setPid(int pid) {
		this.pid = pid;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}
	
}
